Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
retext-visit
Advanced tools
retext node visitor.
npm:
$ npm install retext-visit
Component:
$ component install wooorm/retext-visit
Bower:
$ bower install retext-visit
var Retext,
retext,
visit;
Retext = require('retext');
visit = require('retext-visit');
retext = new Retext().use(visit);
The below examples uses retext 0.2.0, which is currently in beta. For an example with the stable retext, see retext-visit@0.1.0.
retext.parse('A simple English sentence.', function (err, tree) {
if (err) throw err;
/**
* Visit every node in the first sentence.
*/
tree.head.head.visit(function (node) {
console.log(node.toString(), node.type);
});
/**
* 'A', 'WordNode'
* 'A', 'TextNode'
* ' ', 'WhiteSpaceNode'
* ' ', 'TextNode'
* 'simple', 'WordNode'
* 'simple', 'TextNode'
* ' ', 'WhiteSpaceNode'
* ' ', 'TextNode'
* 'English', 'WordNode'
* 'English', 'TextNode'
* ' ', 'WhiteSpaceNode'
* ' ', 'TextNode'
* 'sentence', 'WordNode'
* 'sentence', 'TextNode'
* '.', 'PunctuationNode'
* '.', 'TextNode'
*/
});
Invoke callback
for every descendant of the operated on context.
callback
(function(Node): boolean?
): Visitor. Stops visiting when the return value is false
.retext.parse('A simple English sentence.', function (err, tree) {
if (err) throw err;
/**
* Visit every word node.
*/
tree.visitType(tree.WORD_NODE, function (node) {
console.log(node.toString(), node.type);
});
/**
* 'A', 'WordNode'
* 'simple', 'WordNode'
* 'English', 'WordNode'
* 'sentence', 'WordNode'
*/
});
Invoke callback
for every descendant with a given type
in the operated on context.
type
(string
): Type of the nodes to visit.callback
(function(Node): boolean?
): Visitor. Stops visiting when the return value is false
.MIT © Titus Wormer
FAQs
Deprecated
We found that retext-visit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.